package Day2025_02_24;

import java.util.Scanner;

public class NowCoderDP35 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt(), q = in.nextInt();
        int[][] nums = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                nums[i][j] = in.nextInt();
            }
        }
        long[][] dp = new long[n + 1][m + 1];
        for (int i = 0; i <= n; i++) dp[i][0] = 0;
        for (int i = 0; i <= m; i++) dp[0][i] = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + nums[i - 1][j - 1];
            }
        }
        while (q != 0) {
            int x1 = in.nextInt(), x2 = in.nextInt();
            int x3 = in.nextInt(), x4 = in.nextInt();
            System.out.println(dp[x3][x4] - dp[x3][x2 - 1] - dp[x1 - 1][x4] + dp[x1 - 1][x2 - 1]);
            q--;
        }
    }
}
